package com.itstherules.jmsunit.expectation.xml.xpath;

import java.io.IOException;

import org.custommonkey.xmlunit.XMLAssert;
import org.custommonkey.xmlunit.exceptions.XpathException;
import org.xml.sax.SAXException;

public class XPathDoesntExistExpectation extends BaseXPathExpectation {

	private final String xPath;

	public XPathDoesntExistExpectation(String xPath) {
		if (xPath == null) throw new IllegalArgumentException("xPath expression cannot be null");
		this.xPath = xPath;
	}
	
	protected final void computeSpecific(String actualXml) throws XpathException, IOException, SAXException {
		XMLAssert.assertXpathNotExists(xPath, actualXml);
	}
	
	@Override
	public String toString() {
		StringBuffer buffer = new StringBuffer("XPath doesnt exist expectation (expected nothing to exist at XPath ");
		buffer.append(xPath);
		buffer.append(")");
		return buffer.toString();
	}
}
